package com.app.admin.controller;

import com.app.common.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.List;

@RequestMapping("/api/home")
@Controller
public class HomeController {

    @GetMapping("/dashboard")
    public String dashboard(Model model) {
        model.addAttribute("pageTitle", "系统仪表板");
        return "dashboard";
    }

    @GetMapping("/users")
    public String userList(Model model) {
        // 模拟用户数据
        List<User> users = Arrays.asList(
                new User( "admin", "admin@example.com", "ADMIN"),
                new User( "user1", "user1@example.com", "USER"),
                new User("user2", "user2@example.com", "USER")
        );
        model.addAttribute("users", users);
        model.addAttribute("pageTitle", "用户管理");
        return "user-list";
    }

    @GetMapping("/settings")
    public String settings(Model model) {
        model.addAttribute("pageTitle", "系统设置");
        return "/api/settings";
    }
}